import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {SellerForm, SellerQuery, SellerVO} from "@/api/retail/seller/types";
import {ProfitRatioVO} from "@/api/retail/profitRatio/types";

/**
 * 查询销售员信息列表
 * @param query
 * @returns {*}
 */

export const listSeller = (query?: SellerQuery): AxiosPromise<SellerVO[]> => {
  return request({
    url: '/merchant/seller/list',
    method: 'get',
    params: query
  });
};


/**
 * 查询售货员详细
 * @param id
 */
export const getSeller = (id: string | number): AxiosPromise<SellerVO> => {
  return request({
    url: '/merchant/seller/' + id,
    method: 'get'
  });
};

export const changeSellerStatus = (id: string | number,status: string | number) => {
  const data = {
    id,
    status
  };
  return request({
    url: '/merchant/seller/changeStatus',
    method: 'put',
    data: data
  });
}

export const getAccountList = (id: string | number | Array<string | number>) => {
  return request({
    url: '/merchant/seller/account/' + id,
    method: 'get'
  });
};

export const getProfitConfig = (sellerId?: string | number): AxiosPromise<ProfitRatioVO[]> => {
  return request({
    url: '/merchant/seller/profitRatio/' + sellerId,
    method: 'get'
  });
}

/**
 * 新增售货员
 * @param data
 */
export const addSeller = (data: SellerForm) => {
  return request({
    url: '/merchant/seller',
    method: 'post',
    data: data
  });
};

/**
 * 修改售货员
 * @param data
 */
export const updateSeller = (data: SellerForm) => {
  return request({
    url: '/merchant/seller',
    method: 'put',
    data: data
  });
};
